#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 200007, inf = 1000000;

int n, m;
vector<int> e[N];
bool st[N];
int cnt;

void dfs(int u){
    st[u] = true;
    cnt ++;
    
    if(cnt >= inf) return;
    for(int i = 0; i < e[u].size(); i ++){
        if(!st[e[u][i]] && cnt < inf){
            dfs(e[u][i]);
        }
    }
    st[u] = false;
}

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    int a, b;
    for(int i = 1; i <= m; i ++){
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    dfs(1);
    cout << min(cnt, inf) << '\n';

    return 0;
}